<?php
include "../../lib/list.php";
if($_POST['id']){
	$id = clean($_POST['id']);
	$sear_id = " and id = '$id'";
}

$qry  = "select * from uniaimlogin where 1 $sear_id and db_no = ".$_SESSION['IS_DB_IDX'];
$list = MDBarray($qry);

if(empty($id)){
	$chk_result = 'ID를 입력해 주세요.';
}
else if(!ereg("[a-zA-Z0-9]{4,12}", $id)){
	$chk_result = 'ID는 영어와 숫자조합과<br>4자리보다 크거나 12자리보다 작아야만 합니다.';
}
else{
	if(!$list){
		$chk_result = '<font color=blue>'.$id.'을(를) 사용가능합니다.</font>';
		$chk = 1;
	}else{
		$chk_result = '<font color=red>이미 다른 ID가 존재합니다.</font>';
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../css/insert.css" type="text/css"></link>
<link rel="stylesheet" href="../../css/list.css" type="text/css"></link>
<script>
function insert(){
	var id = document.chk_id.new_id.value;
	opener.insert_id(id);
	window.close();
}
</script>
</head>
<body>
	<div style="width: 320px; padding: 10px;">
		<div
			style="border-bottom: 1px solid #e8e8e8; text-align: left; font-size: 12px; margin-bottom: 12px; color: #9a9a9a">:::
			중복 검사</div>
		<form id="chk_id" method="post" action="chk_id.php" name='chk_id'>
			<input type="hidden" id="new_id" name='new_id' value="<?=$id?>"></input>
			<div id=register>
				<ul class='line'></ul>
				<ul>
					<li class='value' style="margin-left: 7px;"><input type='text'
						size='20' id='id' value='<?=$id?>' name='id'/> <input type='submit'
						class='button green small' value='중복확인' style="width: 100px;" /></li>
				</ul>
				<ul style="padding-top: 8px; margin: 0px; text-align: center;">
					<li><?=$chk_result?></li>
				</ul>
				<ul class='line'></ul>
			</div>
		</form>
		<div style="padding: 5px;">
			<center>
			<?if($chk == 1)echo "<input
				type='button' class='button blue small' value='입력하기' onclick='javacsript:insert()'/>";?>
				<input type="button" class="button white small" value="취소하기"
					onclick="javacsript:window.close()" />
			</center>
		</div>
	</div>
</body>
</html>